import { Loading, MessageBox } from 'element-ui'
let loadingInstance
export default {
  testlog: function () {
    console.log('123')
  },
  open: function () {
    loadingInstance = Loading.service({
      lock: true,
      text: 'Loading',
      spinner: 'el-icon-loading',
      background: 'rgba(0, 0, 0, 0.7)'
    })
  },
  close: function () {
    loadingInstance.close()
  },
  messageTwo (message, title) {
    MessageBox.alert(message, title, {
      confirmButtonText: '确定'
    })
  },
  catchbox (that) {
    that.$pub.close()
    that.$router.push({ name: 'inforAdd' })
  },
  failcode (that, code, message) {
    if (code === 401) {
      MessageBox.alert('登录超时，请退出重新登录', '提示信息', {
        confirmButtonText: '确定',
        callback: action => {
          that.$router.push({ name: 'login' })
          return false
        }
      })
    }
    if (code === -1) {
      MessageBox.alert(message, '提示信息', {
        confirmButtonText: '确定',
        callback: action => {
          return false
        }
      })
    }
  }
}
